﻿// JavaScript Document
$(document).ready(function(){
	var allTitle = $('.Page_Title');  //获取页面上所有栏目标题
	allTitle.mouseover(function(){
		if($(this).find('a:eq(0)').css('height')!=null){
			$(this).find('a:eq(0)').css('backgroundImage','url(images/pro_all_hover.jpg)');
		}
	})
	allTitle.mouseleave(function(){
		if($(this).find('a:eq(0)').css('height')!=null){
			$(this).find('a:eq(0)').css('backgroundImage','url(images/pro_all.jpg)');
		}
	})
	var allUserPic = $('.Pro_Focus');  //获取页面上所有用户和社团小图片
	allUserPic.mouseover(function(){
		$(this).stop(true).animate({'opacity':'0.7','borderBottom':'5px solid #09f'},'fast')
	})
	allUserPic.mouseleave(function(){
		$(this).stop(true).animate({'opacity':'1','borderBottom':'5px solid #FFF'},'fast')
	})
	var homeBtn = $('.Pro_Main table td input');  //获取主页中的两个按钮
	homeBtn.mouseover(function(){
		$(this).stop(true).animate({'opacity':'0.6'},'fast')
	})
	homeBtn.mouseleave(function(){
		$(this).stop(true).animate({'opacity':'1'},'fast')
	})
	
	var allMenu = $('.Pro_Menu li a');  //获取右边的菜单
	allMenu.mouseover(function(){
		$(this).stop(true).animate({'padding-left':'21px'},'fast');
	})
	allMenu.mouseleave(function(){
		$(this).stop(true).animate({'padding-left':'11px'},'fast');
	})
	var planBtn = $('#Plan_Btn');  //获取修改计划按钮
	var makeBtn = $('#Make_Btn');  //获取修改社团规划按钮
	var lawBtn = $('#Law_Btn');  //获取修改规章制度按钮
	var planForm = '<form style="width:700px;display:none;" action="Club?sp='+name+'&action=edit" method="post"><textarea name="content" id="Plan_Redactor" style="height:200px;"></textarea><input type="button" class="Join_Btn" value="取消" style="float:right;margin:10px;" onclick="$(this.parentNode).slideUp();"><input type="submit" class="Join_Btn" value="保存" style="float:right;margin:10px;"></form>'
	planBtn.click(displayEditer)
	makeBtn.click(displayEditer)
	lawBtn.click(displayEditer)
	function displayEditer(){
		
		if($(((this.parentNode).parentNode).parentNode).find('form:eq(0)').html()==null){
			$((this.parentNode).parentNode).after(planForm);
			$('#Plan_Redactor').redactor({ 
				buttons: ['html', '|', 'formatting', '|', 'bold', 'italic', 'deleted', '|',
		'unorderedlist', 'orderedlist', 'outdent', 'indent', '|',
		'image', 'video', 'file', 'table', 'link', '|',
		'alignleft', 'aligncenter', 'alignright', 'justify', '|',
		 'fullscreen'],
				fixed: true	
			});  //为文本框启用文本编辑器
			if($((this.parentNode).parentNode).find('.Plan_Info').html()!=""){
				$('#Plan_Redactor').setCode($((this.parentNode).parentNode).find('.Plan_Info').html());
				$(((this.parentNode).parentNode).parentNode).find('form:eq(0)').slideToggle(function(){$(document).scrollTop($(document).height());});
				$('#Plan_Redactor').setFocus();
			}
		}
		else{
			$(((this.parentNode).parentNode).parentNode).find('form:eq(0)').slideToggle(function(){$(document).scrollTop($(document).height());});
			$('#Plan_Redactor').setFocus();
		}
	}
	
	var noticeBtn = $('.Pro_Change .Notice_Btn');  //获取发送通知按钮
	noticeBtn.click(function(){
		$('.Notice_Box').slideToggle(200);
		var id = getMatesId()
		$('#ID').find(":hidden").attr('value',id)
	})
	
	var allCheckBox = $('.Club_Mates .Select_Mate');  //获取成员页面中的复选框
	var deleteMates = $('.Edit_Mate_Btn');  //获取页面中的批量删除按钮
	deleteMates.click(function(){
		if(getMatesId()==null)
			alert('请至少选择一位成员！')
		else
			var id = getMatesId()
			location.href='Club?sp=cor&action=del&type=batch&id='+id;
	})
	function getMatesId(){
		var MatesId = null; //声明一个字符串存储ID
		allCheckBox.each(function(){
			if($(this).attr('checked'))
				if(MatesId==null)
					MatesId = $(this).attr('_MatesId');
				else
					MatesId += ',' + $(this).attr('_MatesId');
		})
		return MatesId;
	}
	
	
	//启用领域选取函数
	$('.Article_Field').mouseover(function(){articleFieldSelect('one');})
})